import axios from 'axios';

const http = axios.create({
  baseURL: 'http://1.14.239.98/backend/api/v1',
  timeout: 8000
});

/* 请求拦截 */
http.interceptors.request.use((config) => {
  const token = localStorage.getItem('token');
  if (token) config.headers.Authorization = `Bearer ${token}`;
  return config;
}, (error) => Promise.reject(error));

/* 响应拦截 */
http.interceptors.response.use((response) => response.data, (error) => error);

export default http;